package com.reebake.ideal.storage.client;

import cn.hutool.core.io.file.FileNameUtil;
import cn.hutool.http.ContentType;
import com.reebake.ideal.storage.entity.BytesMultipartFile;
import com.reebake.ideal.storage.entity.FileInfoDTO;
import com.reebake.ideal.storage.entity.FileUploadRequestDTO;
import org.springframework.http.MediaTypeFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;

public interface FileUploadClient {

    public default FileInfoDTO upload(String filename, byte[] bytes) {
        return upload(null, new BytesMultipartFile(filename, bytes));
    }

    public default FileInfoDTO upload(String path, MultipartFile file) {
        return upload(null, path, null, file);
    }

    public default FileInfoDTO upload(String platform, String path, MultipartFile file) {
        return upload(platform, path, null, file);
    }

    @PostMapping("/upload")
    FileInfoDTO upload(@RequestParam String platform, @RequestParam String path, @RequestParam String originalFilename, @RequestParam MultipartFile file);

    public default FileInfoDTO uploadImage(String path, MultipartFile file) {
        return upload(null, path, null, file);
    }

    public default FileInfoDTO uploadImage(String platform, String path, MultipartFile file) {
        return upload(platform, path, null, file);
    }

    @PostMapping("/upload-image")
    FileInfoDTO uploadImage(@RequestParam String platform, @RequestParam String path, @RequestParam String originalFilename
            , @RequestParam String waterMarkText, @RequestParam Boolean useThumbnail
            , @RequestParam MultipartFile file);

    @PostMapping("/upload-base64")
    FileInfoDTO upload(FileUploadRequestDTO file);

}
